<template>
  <el-card 
    class="blog-item masonry-item"
    :body-style="{ padding: '0px' }"
  >
    <!-- <a :href="item.link" class="card-link"> -->
      <el-image 
        :src="item.image" 
        class="blog-image" 
        :alt="item.title" 
        fit="cover"
        :preview-src-list="[item.image]"
      >
                <template #placeholder>
                  <div class="image-slot">
                    <el-icon><i-ep-loading /></el-icon>
                  </div>
                </template>
                <template #error>
                  <div class="image-slot">
                    <el-icon><i-ep-picture /></el-icon>
                  </div>
                </template>
              </el-image>
              <div class="card-content">
                <h3 class="card-title">{{ item.title }}</h3>
                <div class="price-section">
                  <span class="template-price">{{ item.rating }}</span>
                </div>
                <p class="card-description">{{ item.description }}</p>
                <div class="card-actions">
                  <router-link :to="`/show/${item.id}`">
                      <el-button type="primary" link class="resources-btn">
                          Read more
                          <el-icon><i-ep-arrow-right /></el-icon>
                      </el-button>
                  </router-link>
                  
                </div>
              </div>
  </el-card>
</template>

<script setup>

const props = defineProps({
  item: {
    type: Object,
    required: true
  }
});
</script>

<style scoped>
.blog-item {
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.blog-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.blog-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.card-content {
  padding: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #303133;
  line-height: 1.4;
  word-break: break-word;
}

.price-section {
  margin-bottom: 12px;
}

.template-price {
  color: #67C23A;
  font-weight: bold;
  font-size: 1.1rem;
  margin-right: 10px;
}

.template-original-price {
  text-decoration: line-through;
  color: #909399;
  font-size: 0.9rem;
}

.card-description {
   font-size: 14px;  /* 正文标准大小 */
  color: #606266;
  line-height: 1.5; /* 优化可读性 */
  margin-bottom: 16px;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-actions {
  text-align: right;
}

.resources-btn {
  color: #409EFF;
  font-weight: 500;
  white-space: nowrap;
}

.image-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 200px;
  background: #f5f7fa;
  color: #909399;
}

.image-slot .el-icon {
  font-size: 30px;
}

a:hover {
  text-decoration: none;
}

/* 增强的响应式设计 */
@media (max-width: 1024px) {
  .blog-image {
    height: 190px;
  }
  

}

@media (max-width: 768px) {
  .blog-image {
    height: 180px;
  }

}

@media (max-width: 576px) {
  .blog-image {
    height: 170px;
  }
}

@media (max-width: 414px) {
  .blog-image {
    height: 160px;
  }
}
</style>